<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>XHH 管理器</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            background: #1a1a1a;
            color: #ffffff;
            line-height: 1.6;
        }

        .header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            padding: 20px 0;
            box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
        }

        .header-content {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .logo {
            font-size: 28px;
            font-weight: bold;
            color: white;
        }

        .nav {
            display: flex;
            gap: 30px;
        }

        .nav-item {
            color: white;
            text-decoration: none;
            padding: 10px 20px;
            border-radius: 8px;
            transition: all 0.3s ease;
            font-weight: 500;
        }

        .nav-item:hover {
            background: rgba(255, 255, 255, 0.2);
            transform: translateY(-2px);
        }

        .nav-item.active {
            background: rgba(255, 255, 255, 0.3);
        }

        .main-content {
            max-width: 1200px;
            margin: 0 auto;
            padding: 40px 20px;
        }

        .welcome-section {
            text-align: center;
            margin-bottom: 60px;
        }

        .welcome-title {
            font-size: 36px;
            font-weight: bold;
            margin-bottom: 16px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        .welcome-subtitle {
            font-size: 18px;
            color: #888;
            margin-bottom: 40px;
        }

        .features-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 30px;
            margin-bottom: 60px;
        }

        .feature-card {
            background: #2a2a2a;
            border-radius: 16px;
            padding: 30px;
            text-align: center;
            transition: all 0.3s ease;
            border: 1px solid #333;
        }

        .feature-card:hover {
            transform: translateY(-8px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
            border-color: #667eea;
        }

        .feature-icon {
            font-size: 48px;
            margin-bottom: 20px;
        }

        .feature-title {
            font-size: 24px;
            font-weight: bold;
            margin-bottom: 16px;
            color: #ffffff;
        }

        .feature-description {
            color: #888;
            margin-bottom: 24px;
            line-height: 1.6;
        }

        .feature-btn {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            padding: 12px 24px;
            border-radius: 8px;
            cursor: pointer;
            font-size: 16px;
            font-weight: bold;
            transition: all 0.3s ease;
            text-decoration: none;
            display: inline-block;
        }

        .feature-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
        }

        .stats-section {
            background: #2a2a2a;
            border-radius: 16px;
            padding: 40px;
            margin-bottom: 40px;
        }

        .stats-title {
            font-size: 24px;
            font-weight: bold;
            margin-bottom: 30px;
            text-align: center;
        }

        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 30px;
        }

        .stat-item {
            text-align: center;
        }

        .stat-number {
            font-size: 36px;
            font-weight: bold;
            color: #667eea;
            margin-bottom: 8px;
        }

        .stat-label {
            color: #888;
            font-size: 14px;
        }

        .quick-actions {
            background: #2a2a2a;
            border-radius: 16px;
            padding: 40px;
        }

        .quick-actions-title {
            font-size: 24px;
            font-weight: bold;
            margin-bottom: 30px;
            text-align: center;
        }

        .actions-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
        }

        .action-btn {
            background: #333;
            border: 1px solid #555;
            color: white;
            padding: 16px 24px;
            border-radius: 8px;
            cursor: pointer;
            font-size: 16px;
            font-weight: bold;
            transition: all 0.3s ease;
            text-decoration: none;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 12px;
        }

        .action-btn:hover {
            background: #444;
            border-color: #667eea;
            transform: translateY(-2px);
        }

        .action-icon {
            font-size: 20px;
        }

        @media (max-width: 768px) {
            .header-content {
                flex-direction: column;
                gap: 20px;
            }

            .nav {
                flex-wrap: wrap;
                justify-content: center;
            }

            .welcome-title {
                font-size: 28px;
            }

            .features-grid {
                grid-template-columns: 1fr;
            }
        }
    </style>
</head>
<body>
    <header class="header">
        <div class="header-content">
            <div class="logo">🎯 XHH 管理器</div>
            <nav class="nav">
                <a href="/xhh/manager/index.html" class="nav-item active">提示词管理</a>
                <a href="/xhh/lora-manager" class="nav-item">LoRA管理</a>
                <a href="/xhh/manager/categories.html" class="nav-item">基础分类</a>
                <a href="/xhh/prompt-manager" class="nav-item">提示词库</a>
            </nav>
        </div>
    </header>

    <main class="main-content">
        <section class="welcome-section">
            <h1 class="welcome-title">欢迎使用 XHH 管理器</h1>
            <p class="welcome-subtitle">一站式AI模型管理和提示词优化平台</p>
        </section>

        <section class="features-grid">
            <div class="feature-card">
                <div class="feature-icon">📝</div>
                <h3 class="feature-title">提示词管理</h3>
                <p class="feature-description">智能管理您的提示词库，支持分类、搜索、收藏等功能，让创作更高效。</p>
                <a href="/xhh/prompt-manager" class="feature-btn">进入管理</a>
            </div>

            <div class="feature-card">
                <div class="feature-icon">🎯</div>
                <h3 class="feature-title">LoRA管理</h3>
                <p class="feature-description">管理您的LoRA模型库，支持标签分类、图片预览、使用统计等功能。</p>
                <a href="/xhh/lora-manager" class="feature-btn">进入管理</a>
            </div>

            <div class="feature-card">
                <div class="feature-icon">🏷️</div>
                <h3 class="feature-title">基础分类</h3>
                <p class="feature-description">丰富的服装、发型、鞋类等基础分类，为不同模型提供标准化的提示词。</p>
                <a href="/xhh/manager/categories.html" class="feature-btn">查看分类</a>
            </div>
        </section>

        <section class="stats-section">
            <h2 class="stats-title">数据统计</h2>
            <div class="stats-grid">
                <div class="stat-item">
                    <div class="stat-number" id="promptCount">0</div>
                    <div class="stat-label">提示词总数</div>
                </div>
                <div class="stat-item">
                    <div class="stat-number" id="loraCount">0</div>
                    <div class="stat-label">LoRA模型数</div>
                </div>
                <div class="stat-item">
                    <div class="stat-number" id="categoryCount">0</div>
                    <div class="stat-label">分类数量</div>
                </div>
                <div class="stat-item">
                    <div class="stat-number" id="imageCount">0</div>
                    <div class="stat-label">图片总数</div>
                </div>
            </div>
        </section>

        <section class="quick-actions">
            <h2 class="quick-actions-title">快速操作</h2>
            <div class="actions-grid">
                <a href="/xhh/prompt-manager" class="action-btn">
                    <span class="action-icon">📝</span>
                    <span>管理提示词</span>
                </a>
                <a href="/xhh/lora-manager" class="action-btn">
                    <span class="action-icon">🎯</span>
                    <span>管理LoRA</span>
                </a>
                <a href="/xhh/manager/categories.html" class="action-btn">
                    <span class="action-icon">🏷️</span>
                    <span>基础分类</span>
                </a>
                <a href="/xhh/manager/models.html" class="action-btn">
                    <span class="action-icon">🤖</span>
                    <span>模型测试</span>
                </a>
            </div>
        </section>
    </main>

    <script>
        // 加载统计数据
        async function loadStats() {
            try {
                console.log("📊 开始加载统计数据");
                
                // 加载提示词数量
                try {
                    const promptResponse = await fetch('/api/xhh/prompts?page=1&per_page=1');
                    const promptData = await promptResponse.json();
                    console.log("📊 提示词数据:", promptData);
                    if (promptData.success && promptData.data && promptData.data.pagination) {
                        document.getElementById('promptCount').textContent = promptData.data.pagination.total;
                        console.log("📊 提示词数量:", promptData.data.pagination.total);
                    }
                } catch (error) {
                    console.error("📊 加载提示词数量失败:", error);
                }

                // 加载LoRA数量
                try {
                    const loraResponse = await fetch('/api/xhh/lora-list');
                    const loraData = await loraResponse.json();
                    console.log("📊 LoRA数据:", loraData);
                    if (loraData.success && loraData.data) {
                        document.getElementById('loraCount').textContent = loraData.data.length;
                        console.log("📊 LoRA数量:", loraData.data.length);
                    }
                } catch (error) {
                    console.error("📊 加载LoRA数量失败:", error);
                }

                // 加载分类数量
                try {
                    const categoryResponse = await fetch('/api/xhh/categories');
                    const categoryData = await categoryResponse.json();
                    console.log("📊 分类数据:", categoryData);
                    if (categoryData.success && categoryData.data) {
                        document.getElementById('categoryCount').textContent = Object.keys(categoryData.data).length;
                        console.log("📊 分类数量:", Object.keys(categoryData.data).length);
                    }
                } catch (error) {
                    console.error("📊 加载分类数量失败:", error);
                }

                // 加载图片数量
                try {
                    const imageResponse = await fetch('/api/xhh/images');
                    const imageData = await imageResponse.json();
                    console.log("📊 图片数据:", imageData);
                    if (imageData.success && imageData.data) {
                        document.getElementById('imageCount').textContent = imageData.data.length;
                        console.log("📊 图片数量:", imageData.data.length);
                    }
                } catch (error) {
                    console.error("📊 加载图片数量失败:", error);
                }

            } catch (error) {
                console.error('加载统计数据失败:', error);
            }
        }

        // 页面加载完成后执行
        document.addEventListener('DOMContentLoaded', loadStats);
    </script>
</body>
</html>
